#include <cstdio>
#include "data_pool.h"
#include "example_simple.h"

typedef data_pool<simple> simple_pool;
typedef inclosure_elem<simple> simple_elem;

int main(int argc, char const *argv[])
{
    simple_elem elem = simple_pool::getInstance().get();
    elem->num = 100;
    printf("elem->num: %d\n", elem->num);

    elem = simple_pool::getInstance().get();
    elem->num = 200;
    printf("elem->num: %d\n", elem->num);

    elem = simple_pool::getInstance().get();
    elem->num = 300;
    printf("elem->num: %d\n", elem->num);

    elem = simple_pool::getInstance().get();
    elem->num = 400;
    printf("elem->num: %d\n", elem->num);

    simple_elem elem1 = simple_pool::getInstance().get();
    
    elem1->num = 1100;
    (*elem1).num += 1200;
    printf("elem->num: %d\n", elem1->num);
    // elem.clear();

    while(!(elem1 = simple_pool::getInstance().get()));
    
    elem1->num = 1200;
    printf("elem->num: %d\n", elem1->num);
    
    while(!(elem1 = simple_pool::getInstance().get()));
    
    elem1->num = 1300;
    printf("elem->num: %d\n", elem1->num);

    while(!(elem1 = simple_pool::getInstance().get()));
    
    elem1->num = 1400;
    printf("elem->num: %d\n", elem1->num);

    return 0;
}
